/**************************************************************
  > File Name: 1.c
  > Author: LuoLiang
  > Mail: 1204553475@qq.com 
  > Created Time: 2022年02月10日 星期四 10时24分39秒
 **************************************************************/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

static int cmp(const void *a, const void *b)
{
	return *(int *)a - *(int *)b;
}

static int cmp1(const void *a, const void *b)
{
	return *(char *)b - *(char *)a;
}

static int cmp2(const void *a, const void *b)
{
	return strcmp(*(char **)a,*(char **)b);
}

static int cmp3(const void *a, const void *b)
{
	int *p = *(int **)a;
	int *q = *(int **)b;
	return p[1] - q[1];
	//return (*(int **)a)[1] - (*(int **)b)[1];
}
int main(int argc,char **argv)
{
	int a[] = {1,3,8,6,2,4,7};
	char b[] = "dacbe";
	char *c[] = {"hell","hello","wordk","abd","zsx"};
	int d[][2] = {{1,2},{2,3},{3,4},{1,3}};
	int *p[4];

	for (int i = 0; i < 4; i++)
	{
		p[i] = d[i];
	}

#if 0
	qsort(a, sizeof(a)/sizeof(*a), sizeof(*a), cmp);
	for (int i = 0; i < 7; i++)
	{
		printf("%d ",a[i]);
	}

	qsort(b, strlen(b), sizeof(char), cmp1);
	puts(b);
	qsort(c, 5, sizeof(char *), cmp2);
	for (int i = 0; i < 5; i++)
	{
		puts(c[i]);
	}
#endif
	
	qsort(p, 4, sizeof(int*), cmp3);
	for (int i = 0; i < 4; i++)
	{
		for (int j = 0; j < 2; j++)
		{
			printf("%d ",d[i][j]);
		}
		printf("\n");
	}

    exit(0);
}
